from django.db import models


# Create your models here.


class User(models.Model):
    sex_choices = (
        (0, "男"),
        (1, "女"),
    )
    username = models.CharField(primary_key=True, max_length=20, verbose_name="用户名")
    password = models.CharField(max_length=20, verbose_name="密码")
    sex = models.SmallIntegerField(choices=sex_choices, verbose_name="性别")
    phone = models.IntegerField(verbose_name="电话号码")
    email = models.EmailField()

    def __str__(self):
        return self.username


class Spider(models.Model):
    heat_choices = (
        (0, "热度"),
        (1, "关键字"),
        (2, "当当网"),
        (3, "中国新闻网")

    )

    name = models.CharField(max_length=50, verbose_name="爬虫名字")
    hear = models.SmallIntegerField(choices=heat_choices, verbose_name="爬虫类型")

    def __str__(self):
        return self.name


class XinLanSpider(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name="使用用户")
    name = models.CharField(max_length=20, verbose_name="爬虫名称")

    author = models.CharField(max_length=20, verbose_name="作者")
    content = models.TextField(verbose_name="内容")
    move = models.IntegerField(verbose_name="转发")
    comment = models.IntegerField(verbose_name="评论数")
    good = models.IntegerField(verbose_name="点赞")
    classify = models.CharField(verbose_name='类型', max_length=22)

    spider = models.ForeignKey(Spider, on_delete=models.CASCADE, verbose_name="爬虫名称")



